<?php
/* @var $this \yii\web\View */
/* @var $dataProvider*/
/* @var $parentModel*/
$Permission = $this->context->permission;
$this->title = $Permission->description . '<small>'.$parentModel->description.'</small>';
$this->params['breadcrumb'] = $breadcrumb;
?>
<div class="row">
    <div class="box">
<?php
echo \backend\components\grid\MyGridView::widget([
    'dataProvider'=>$dataProvider,
    'topButtons' => [
        'add' => function () use ($parentModel) {
            $url = \yii\helpers\Url::toRoute([Yii::$app->controller->id.'/add','pid'=>$parentModel->id]);
            $options = ['class'=>'btn btn-sm btn-primary'];
            return \yii\helpers\Html::a('<i class="fa fa-fw fa-plus-square"></i>新增', $url, $options);
        }
    ],
    'columns' => [
        [
            'class' => \backend\components\grid\MyDataColumn::className(),
            'attribute' => 'id',
        ],
        [
            'attribute' => 'description',
            'content' => function ($model, $key, $index, $column) use ($parentModel) {
                return $parentModel->level == 2 ? $model->description : \yii\helpers\Html::a($model->description,\yii\helpers\Url::toRoute(['/'.Yii::$app->requestedRoute,'pid'=>$model->id]));
            }
        ],
        'arrangement',
        'link',
        [
            'class' => \backend\components\grid\MyActionColumn::className(),
            'template' => '{update} {delete}'
        ]
    ]
]);?>
    </div>
</div>
